/******************************************************************************
 * * setting_display.c - implementation of display setting functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/

#include "setting_global.h"

/* global variable */
Setting_Display_Wall_Paper_t  SettingWallPaterList[SETTING_MAX_WALL_PAPER_NUM];
Setting_Display_Setting_Mng_t g_SettingDisplaySettingMng;
VOID                          *gp_SettingDisplayCurUIDesc              = NULL; // Current UI description
VOID                          *gp_SettingDisplayCurContainerListUIDesc = NULL; // Current UI description
VOID                          *gp_SettingDisplayCurNormalListUIDesc    = NULL; // Current UI description

/**
 * sub-module entry
 * param (in) void
 * return  void
 */
VOID Setting_Display_Main(VOID)
{
    // init manage variable
}

/**
 * sub-module event handler
 * param (in) void
 * return  void
 */
VOID Setting_Display_Event_handle(VOID)
{
    // event and message dispatch
}

/**
 * sub-module entry
 * param (in) BacklightIntensity: SETTING_BACKLIGHT_INTENSITY
 * return intensity: HAL_INTENSITY_LEVEL
 */
HAL_INTENSITY_LEVEL Setting_Backlight_Intensity_To_Hal_Intensity(SETTING_BACKLIGHT_INTENSITY BacklightIntensity)
{
    HAL_INTENSITY_LEVEL intensity;

    switch (BacklightIntensity)
    {
    case SETTING_BACKLIGHT_INTENSITY_1:
        intensity = HAL_INTENSITY_LEVEL_1;
        break;

    case SETTING_BACKLIGHT_INTENSITY_2:
        intensity = HAL_INTENSITY_LEVEL_2;
        break;

    case SETTING_BACKLIGHT_INTENSITY_3:
        intensity = HAL_INTENSITY_LEVEL_3;
        break;

    case SETTING_BACKLIGHT_INTENSITY_4:
        intensity = HAL_INTENSITY_LEVEL_4;
        break;

    case SETTING_BACKLIGHT_INTENSITY_5:
        intensity = HAL_INTENSITY_LEVEL_5;
        break;

    default:
        break;
    }

    return(intensity);
}

/**
 * initiate display sub-module
 * param (in) NvPara: Setting_NVM_Para_t
 * return  void
 */
VOID Setting_Display_Init_Req(NV_UI_Settings_t *pNvPara)
{
    // init manage variable
    g_SettingDisplaySettingMng.CurrentWallPaperIndex = (UINT8)(pNvPara->DisplaySetting.CurrentWallPaperIndex);
    g_SettingDisplaySettingMng.BacklightIntensity    = (SETTING_BACKLIGHT_INTENSITY)(pNvPara->DisplaySetting.BacklightIntensity);
    g_SettingDisplaySettingMng.BacklightTimeout      = (SETTING_BACKLIGHT_TIMEOUT)(pNvPara->DisplaySetting.BacklightTimeout);
    g_SettingDisplaySettingMng.StandbyScreenMode     = (SETTING_STANDBY_SCREEN)(pNvPara->DisplaySetting.StandbyScreenMode);

    SettingWallPaterList[0].WallpaperNameID = PHONE_TEXT_ID_WALLPAPER1;
    SettingWallPaterList[0].WallPaper       = IMG_WALLPAPER_1;
    SettingWallPaterList[1].WallpaperNameID = PHONE_TEXT_ID_WALLPAPER2;
    SettingWallPaterList[1].WallPaper       = IMG_WALLPAPER_1;

    Hal_Backlight_Intensity_Set(Setting_Backlight_Intensity_To_Hal_Intensity(g_SettingDisplaySettingMng.BacklightIntensity));
}

/**
 * get current wall paper
 * param (in) WallPaper: lv_img_dsc_t*
 * return  void
 */
VOID Setting_Get_Wall_Paper_Req(Setting_Wall_Paper_t **WallPaper)
{
    *WallPaper = SettingWallPaterList[g_SettingDisplaySettingMng.CurrentWallPaperIndex].WallPaper;
}

/**
 * get current Backlight Intensity
 * param (in) BacklightIntensity: SETTING_BACKLIGHT_INTENSITY*
 * return  void
 */
VOID Setting_Get_Backlight_Intensity_Req(SETTING_BACKLIGHT_INTENSITY *BacklightIntensity)
{
    UINT8 nvData;

    // nv read
    UI_NV_Read_Req(NV_SECTION_UI_SETTINGS, (NV_SETTING_DISPLAY_SETTING_OFFSET + 1), 1, &nvData);
    *BacklightIntensity = (SETTING_BACKLIGHT_INTENSITY)nvData;
}

/**
 * get current Backlight Intensity
 * param (in) BacklightIntensity: SETTING_BACKLIGHT_INTENSITY*
 * return  void
 */
VOID Setting_Get_Backlight_Time_Out_Req(SETTING_BACKLIGHT_TIMEOUT *Timeout)
{
    UINT8 nvData;

    // nv read
    UI_NV_Read_Req(NV_SECTION_UI_SETTINGS, (NV_SETTING_DISPLAY_SETTING_OFFSET + 2), 1, &nvData);
    *Timeout = (SETTING_BACKLIGHT_TIMEOUT)nvData;
}

/**
 *
 * Get backlight Timer length
 * param (in) VOID
 * return UINT32: in second
 */
UINT32 Setting_Get_Backlight_Timer_Length(VOID)
{
    UINT32 TimerLen = 60;

    switch (g_SettingDisplaySettingMng.BacklightTimeout)
    {
    case SETTING_BACKLIGHT_TIMEOUT_10:
        TimerLen = 10;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_20:
        TimerLen = 20;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_40:
        TimerLen = 40;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_60:
        TimerLen = 60;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_120:
        TimerLen = 120;
        break;

    default:
        break;
    }

    return(TimerLen);
}

/**
 * set wall paper
 * param (in) Index:UINT8
 * return  void
 */
VOID Setting_Set_Wallpaper(UINT8 Index)
{
    UINT8                   nvData;
    Setting_Phone_Setting_t *PhoneSettingChg;

    PhoneSettingChg = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
    Hal_Mem_Set(PhoneSettingChg, 0, sizeof(Setting_Phone_Setting_t));

    // change global variable
    g_SettingDisplaySettingMng.CurrentWallPaperIndex = Index;

    // nv write
    nvData = (UINT8)g_SettingDisplaySettingMng.CurrentWallPaperIndex;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, NV_SETTING_DISPLAY_SETTING_OFFSET, 1, &nvData);

    // inform framework
    PhoneSettingChg->ChangeMark = IF_SETTING_CHANGE_MARK_WALL_PAPER;
    PhoneSettingChg->WallPaper  = SettingWallPaterList[Index].WallPaper;
    Setting_Phone_Setting_Chg_Ind(PhoneSettingChg);
}

/**
 * Callback Function of Setting_Done of Setting_Wallpapers
 * param (in) Btn: lv_obj_t*
 * param (in) Event: lv_event_t
 * return void:
 */
VOID Display_Setting_Done_Setting_Wallpapers_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc1 = NULL; // UI Setting_Display_Settings
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc2 = NULL; // UI Setting_Wallpapers

        NormalContainerListDesc1 = (UI_Normal_Container_List_Desc_t *)gp_SettingDisplayCurContainerListUIDesc;
        NormalContainerListDesc2 = (UI_Normal_Container_List_Desc_t *)gp_SettingDisplayCurUIDesc;

        Setting_Set_Wallpaper(NormalContainerListDesc2->ContList.Index);
        NormalContainerListDesc1->ContList.ContainerList[NormalContainerListDesc1->ContList.Index].u.Label2.TxtId
            = SettingWallPaterList[g_SettingDisplaySettingMng.CurrentWallPaperIndex].WallpaperNameID;

        Display_Setting_Done(ACT_ID_SETTING_WALLPAPERS, PHONE_TEXT_ID_DONE, ACT_ID_SETTING_DISPLAY_SETTINGS);
    }
}

/**
 *
 * Callback of Display_Setting_Wallpapers, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Wallpapers_Destroy(VOID *pPara)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)pPara;

    Hal_Mem_Free(NormalContainerListDesc->ContList.ContainerList);
    Hal_Mem_Free(NormalContainerListDesc);
}

/**
 *
 * Display_Setting_Wallpapers_KeyCb
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Wallpapers_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)gp_SettingDisplayCurUIDesc;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    if (KEY_DOWN == key_val)
    {
        NormalContainerListDesc->ContList.Index++;
        NormalContainerListDesc->ContList.Index %= NormalContainerListDesc->ContList.ListContainerCnt;
        return(0);
    }
    else if (KEY_UP == key_val)
    {
        NormalContainerListDesc->ContList.Index += NormalContainerListDesc->ContList.ListContainerCnt;
        NormalContainerListDesc->ContList.Index--;
        NormalContainerListDesc->ContList.Index %= NormalContainerListDesc->ContList.ListContainerCnt;
        return(0);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // return to previous UI
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
}

/**
 * display Setting_Wallpapers
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Wallpapers(VOID)
{
    UINT8                           ListContainerCnt         = 0;
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;
    UI_Container_Base_Desc_t        *ContainerList           = NULL;
    Nav_Func_List_t                 FuncList;

    ListContainerCnt = 2;
    ContainerList    = (UI_Container_Base_Desc_t *)Hal_Mem_Alloc(ListContainerCnt * sizeof(UI_Container_Base_Desc_t));
    Hal_Mem_Set(ContainerList, 0, ListContainerCnt * sizeof(UI_Container_Base_Desc_t));

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(NormalContainerListDesc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    NormalContainerListDesc->TitleBar.TxtId      = PHONE_TEXT_ID_WALLPAPER;
    NormalContainerListDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    NormalContainerListDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;

    ContainerList[0].Label.TxtId      = PHONE_TEXT_ID_WALLPAPER1;
    ContainerList[0].Label.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    ContainerList[0].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[0].Valid            = TRUE;
    ContainerList[0].Choise           = UI_BASE_OBJ_IMG;
    ContainerList[0].u.Img.Img        = IMG_WALLPAPER_1_S;
    ContainerList[0].u.Img.ImgAlign   = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[0].ReleaseFunc      = Display_Setting_Done_Setting_Wallpapers_Cb;

    ContainerList[1].Label.TxtId      = PHONE_TEXT_ID_WALLPAPER2;
    ContainerList[1].Label.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    ContainerList[1].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[1].Valid            = TRUE;
    ContainerList[1].Choise           = UI_BASE_OBJ_IMG;
    ContainerList[1].u.Img.Img        = IMG_WALLPAPER_1_S;
    ContainerList[1].u.Img.ImgAlign   = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[1].ReleaseFunc      = Display_Setting_Done_Setting_Wallpapers_Cb;

    NormalContainerListDesc->ContList.ListContainerCnt = ListContainerCnt;
    NormalContainerListDesc->ContList.Index            = 0;
    NormalContainerListDesc->ContList.ContainerList    = ContainerList;

    NormalContainerListDesc->ButtonBar.ButtonL.Valid = FALSE;

    NormalContainerListDesc->ButtonBar.ButtonM.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;

    NormalContainerListDesc->ButtonBar.ButtonR.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalContainerListDesc->KeyFunc = Display_Setting_Wallpapers_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_Container_List_Create;
    FuncList.OnDestroy = Display_Setting_Wallpapers_Destroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_WALLPAPERS, &FuncList, (VOID *)NormalContainerListDesc);
    gp_SettingDisplayCurUIDesc = (VOID *)NormalContainerListDesc;
} /* Display_Setting_Wallpapers */

/**
 * Callback Function of Setting_Wallpapers
 * param (in) Btn: lv_obj_t*
 * param (in) Event: lv_event_t
 * return void:
 */
VOID Display_Setting_Wallpapers_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Wallpapers();
    }
}

/**
 * sub-module entry
 * param (in) BarValue: UINT8
 * return BacklightIntensity: SETTING_BACKLIGHT_INTENSITY
 */
SETTING_BACKLIGHT_INTENSITY Setting_Backlight_Bar_Value_To_Intensity(UINT8 BarValue)
{
    SETTING_BACKLIGHT_INTENSITY BacklightIntensity;

    switch (BarValue)
    {
    case 0:
        BacklightIntensity = SETTING_BACKLIGHT_INTENSITY_1;
        break;

    case 1:
        BacklightIntensity = SETTING_BACKLIGHT_INTENSITY_2;
        break;

    case 2:
        BacklightIntensity = SETTING_BACKLIGHT_INTENSITY_3;
        break;

    case 3:
        BacklightIntensity = SETTING_BACKLIGHT_INTENSITY_4;
        break;

    case 4:
        BacklightIntensity = SETTING_BACKLIGHT_INTENSITY_5;
        break;

    default:
        BacklightIntensity = SETTING_BACKLIGHT_INTENSITY_1;
        break;
    }

    return(BacklightIntensity);
}

/**
 * sub-module entry
 * param (in) BacklightIntensity: SETTING_BACKLIGHT_INTENSITY
 * return BarValue: UINT8
 */
UINT8 Setting_Backlight_Intensity_To_Bar_Value(SETTING_BACKLIGHT_INTENSITY BacklightIntensity)
{
    UINT8 BarValue;

    switch (BacklightIntensity)
    {
    case SETTING_BACKLIGHT_INTENSITY_1:
        BarValue = 0;
        break;

    case SETTING_BACKLIGHT_INTENSITY_2:
        BarValue = 1;
        break;

    case SETTING_BACKLIGHT_INTENSITY_3:
        BarValue = 2;
        break;

    case SETTING_BACKLIGHT_INTENSITY_4:
        BarValue = 3;
        break;

    case SETTING_BACKLIGHT_INTENSITY_5:
        BarValue = 4;
        break;

    default:
        break;
    }

    return(BarValue);
}

/**
 * sub-module entry
 * param (in) BacklightTimeout: SETTING_BACKLIGHT_TIMEOUT
 * return TxtId: UINT16
 */
UINT16 Setting_Backlight_Timeout_To_TxtId(SETTING_BACKLIGHT_TIMEOUT BacklightTimeout)
{
    UINT16 TxtId = LV_LANG_TXT_ID_NONE;

    switch (BacklightTimeout)
    {
    case SETTING_BACKLIGHT_TIMEOUT_10:
        TxtId = PHONE_TEXT_ID_10SEC;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_20:
        TxtId = PHONE_TEXT_ID_20SEC;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_40:
        TxtId = PHONE_TEXT_ID_40SEC;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_60:
        TxtId = PHONE_TEXT_ID_60SEC;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_120:
        TxtId = PHONE_TEXT_ID_120SEC;
        break;

    default:
        break;
    }

    return(TxtId);
}

/**
 * sub-module entry
 * param (in) TxtId: UINT16
 * return  BacklightTimeout: SETTING_BACKLIGHT_TIMEOUT
 */
SETTING_BACKLIGHT_TIMEOUT Setting_TxtId_To_Backlight_Timeout(UINT16 TxtId)
{
    SETTING_BACKLIGHT_TIMEOUT BacklightTimeout;

    switch (TxtId)
    {
    case PHONE_TEXT_ID_10SEC:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_10;
        break;

    case PHONE_TEXT_ID_20SEC:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_20;
        break;

    case PHONE_TEXT_ID_40SEC:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_40;
        break;

    case PHONE_TEXT_ID_60SEC:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_60;
        break;

    case PHONE_TEXT_ID_120SEC:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_120;
        break;

    default:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_10;
        break;
    }

    return(BacklightTimeout);
}

/**
 * sub-module entry
 * param (in) BacklightTimeout: SETTING_BACKLIGHT_TIMEOUT
 * return ButtonIndex: UINT8
 */
UINT8 Setting_Backlight_Timeout_To_ButtonIndex(SETTING_BACKLIGHT_TIMEOUT BacklightTimeout)
{
    UINT8 ButtonIndex = 0;

    switch (BacklightTimeout)
    {
    case SETTING_BACKLIGHT_TIMEOUT_10:
        ButtonIndex = 0;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_20:
        ButtonIndex = 1;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_40:
        ButtonIndex = 2;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_60:
        ButtonIndex = 3;
        break;

    case SETTING_BACKLIGHT_TIMEOUT_120:
        ButtonIndex = 4;
        break;

    default:
        break;
    }

    return(ButtonIndex);
}

/**
 * sub-module entry
 * param (in) ButtonIndex: UINT8
 * return BacklightTimeout: SETTING_BACKLIGHT_TIMEOUT
 */
SETTING_BACKLIGHT_TIMEOUT Setting_ButtonIndex_To_Backlight_Timeout(UINT8 ButtonIndex)
{
    SETTING_BACKLIGHT_TIMEOUT BacklightTimeout;

    switch (ButtonIndex)
    {
    case 0:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_10;
        break;

    case 1:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_20;
        break;

    case 2:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_40;
        break;

    case 3:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_60;
        break;

    case 4:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_120;
        break;

    default:
        BacklightTimeout = SETTING_BACKLIGHT_TIMEOUT_120;
        break;
    }

    return(BacklightTimeout);
}

/**
 *
 * Callback of Display_Setting_Backlight_Time_Out, on destroy
 * param (in) pNormalLstOnlyDesc: UI_Normal_List_Only_Desc_t*
 * return void:
 */
VOID Display_Setting_Backlight_Time_Out_Destroy(VOID *pPara)
{
    UI_Normal_List_Only_Desc_t *pNormalLstOnlyDesc = NULL;

    pNormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)pPara;

    Hal_Mem_Free(pNormalLstOnlyDesc->List.ButtonList);
    Hal_Mem_Free(pNormalLstOnlyDesc);
}

/**
 *
 * Display_Setting_Backlight_Time_Out_KeyCb
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Backlight_Time_Out_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_List_Only_Desc_t *pNormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)gp_SettingDisplayCurNormalListUIDesc;
    UINT8                      Index               = pNormalLstOnlyDesc->List.Index;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    if (KEY_DOWN == key_val)
    {
        Index++;
        Index %= pNormalLstOnlyDesc->List.ListButtonCnt;

        pNormalLstOnlyDesc->List.Index = Index;

        return(0);
    }
    else if (KEY_UP == key_val)
    {
        Index += pNormalLstOnlyDesc->List.ListButtonCnt;
        Index--;
        Index %= pNormalLstOnlyDesc->List.ListButtonCnt;

        pNormalLstOnlyDesc->List.Index = Index;

        return(0);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // return to previous UI
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
} /* Display_Setting_Backlight_Time_Out_KeyCb */

/**
 * backlight timeout call back
 * param (in) Btn: lv_obj_t*
 * param (in) Event: lv_event_t
 * return  void
 */
VOID Display_Setting_Backlight_Time_Out_CallBack(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UI_Normal_List_Only_Desc_t      *pNormalLstOnlyDesc      = (UI_Normal_List_Only_Desc_t *)gp_SettingDisplayCurNormalListUIDesc;
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)gp_SettingDisplayCurUIDesc;

        // hal trun off Backlight
        NormalContainerListDesc->ContList.ContainerList[1].u.Label2.TxtId = Setting_Backlight_Timeout_To_TxtId(Setting_ButtonIndex_To_Backlight_Timeout(pNormalLstOnlyDesc->List.Index));

        Nav_Back(ACT_ID_ANY);
    }
}

/**
 * display Setting_Backlight_Time_Out
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Backlight_Time_Out(VOID)
{
    Nav_Func_List_t                 FuncList;
    UI_Normal_List_Only_Desc_t      *pNormalLstOnlyDesc      = NULL;
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;  // UI Backlight
    SETTING_BACKLIGHT_TIMEOUT       BacklightTimeout;

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)gp_SettingDisplayCurUIDesc;
    BacklightTimeout        = Setting_TxtId_To_Backlight_Timeout(NormalContainerListDesc->ContList.ContainerList[1].u.Label2.TxtId);

    pNormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pNormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    pNormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_TIME_OUT;
    pNormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pNormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    pNormalLstOnlyDesc->List.Index         = Setting_Backlight_Timeout_To_ButtonIndex(BacklightTimeout);
    pNormalLstOnlyDesc->List.ListButtonCnt = 5;
    pNormalLstOnlyDesc->List.ButtonList    = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * pNormalLstOnlyDesc->List.ListButtonCnt);
    Hal_Mem_Set(pNormalLstOnlyDesc->List.ButtonList, 0, sizeof(UI_Button_Desc_t) * pNormalLstOnlyDesc->List.ListButtonCnt);

    pNormalLstOnlyDesc->List.ButtonList[0].ButtonIndex = 0;
    pNormalLstOnlyDesc->List.ButtonList[0].TxtId       = PHONE_TEXT_ID_10SEC;
    pNormalLstOnlyDesc->List.ButtonList[0].Valid       = TRUE;
    pNormalLstOnlyDesc->List.ButtonList[0].ReleaseFun  = Display_Setting_Backlight_Time_Out_CallBack;

    pNormalLstOnlyDesc->List.ButtonList[1].ButtonIndex = 1;
    pNormalLstOnlyDesc->List.ButtonList[1].TxtId       = PHONE_TEXT_ID_20SEC;
    pNormalLstOnlyDesc->List.ButtonList[1].Valid       = TRUE;
    pNormalLstOnlyDesc->List.ButtonList[1].ReleaseFun  = Display_Setting_Backlight_Time_Out_CallBack;

    pNormalLstOnlyDesc->List.ButtonList[2].ButtonIndex = 2;
    pNormalLstOnlyDesc->List.ButtonList[2].TxtId       = PHONE_TEXT_ID_40SEC;
    pNormalLstOnlyDesc->List.ButtonList[2].Valid       = TRUE;
    pNormalLstOnlyDesc->List.ButtonList[2].ReleaseFun  = Display_Setting_Backlight_Time_Out_CallBack;

    pNormalLstOnlyDesc->List.ButtonList[3].ButtonIndex = 3;
    pNormalLstOnlyDesc->List.ButtonList[3].TxtId       = PHONE_TEXT_ID_60SEC;
    pNormalLstOnlyDesc->List.ButtonList[3].Valid       = TRUE;
    pNormalLstOnlyDesc->List.ButtonList[3].ReleaseFun  = Display_Setting_Backlight_Time_Out_CallBack;

    pNormalLstOnlyDesc->List.ButtonList[4].ButtonIndex = 4;
    pNormalLstOnlyDesc->List.ButtonList[4].TxtId       = PHONE_TEXT_ID_120SEC;
    pNormalLstOnlyDesc->List.ButtonList[4].Valid       = TRUE;
    pNormalLstOnlyDesc->List.ButtonList[4].ReleaseFun  = Display_Setting_Backlight_Time_Out_CallBack;

    pNormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;

    pNormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    pNormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;

    pNormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    pNormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    pNormalLstOnlyDesc->KeyFunc = Display_Setting_Backlight_Time_Out_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_List_Only_Create;
    FuncList.OnDestroy = Display_Setting_Backlight_Time_Out_Destroy;

    Nav_Forward(ACT_ID_SETTING_BACKLIGHT, ACT_ID_SETTING_BACKLIGHT_TIME_OUT, &FuncList, pNormalLstOnlyDesc);
    gp_SettingDisplayCurNormalListUIDesc = (VOID *)pNormalLstOnlyDesc;
} /* Display_Setting_Backlight_Time_Out */

/**
 * set backlight intensity
 * param (in) Level: SETTING_BACKLIGHT_INTENSITY
 * return  void
 */
VOID Setting_Set_Backlight_Intensity(SETTING_BACKLIGHT_INTENSITY Intensity)
{
    // update global variable
    // hal intensity(IntensityLevel[Level])
    UINT8 nvData;

    // change global variable
    g_SettingDisplaySettingMng.BacklightIntensity = Intensity;

    // nv write
    nvData = (UINT8)Intensity;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, (NV_SETTING_DISPLAY_SETTING_OFFSET + 1), 1, &nvData);
}

/**
 * set backlight timeout
 * param (in) Timeout: SETTING_BACKLIGHT_TIMEOUT
 * return  void
 */
VOID Setting_Set_Backlight_Timeout(SETTING_BACKLIGHT_TIMEOUT Timeout)
{
    UINT8 nvData;

    // update global variable
    g_SettingDisplaySettingMng.BacklightTimeout = Timeout;

    // nv write
    nvData = (UINT8)Timeout;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, (NV_SETTING_DISPLAY_SETTING_OFFSET + 2), 1, &nvData);
}

/**
 *
 * Callback of Display_Setting_Backlight, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Backlight_Destroy(VOID *pPara)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)pPara;

    Hal_Mem_Free(NormalContainerListDesc->ContList.ContainerList);
    Hal_Mem_Free(NormalContainerListDesc);
}

/**
 *
 * Display_Setting_Backlight_KeyCb
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Backlight_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)gp_SettingDisplayCurUIDesc;
    UINT8                           Index                    = NormalContainerListDesc->ContList.Index;
    UINT8                           Value                    = 0;
    SETTING_BACKLIGHT_INTENSITY     BacklightIntensity;
    SETTING_BACKLIGHT_TIMEOUT       BacklightTimeout;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    if (KEY_DOWN == key_val)
    {
        Index++;
        Index %= NormalContainerListDesc->ContList.ListContainerCnt;

        NormalContainerListDesc->ContList.Index = Index;
        if (PHONE_TEXT_ID_TIME_OUT == NormalContainerListDesc->ContList.ContainerList[Index].Label.TxtId)
        {
            lv_obj_set_hidden(NormalContainerListDesc->ButtonBar.ButtonL.Button, FALSE);
        }
        else
        {
            lv_obj_set_hidden(NormalContainerListDesc->ButtonBar.ButtonL.Button, TRUE);
        }

        return(0);
    }
    else if (KEY_UP == key_val)
    {
        Index += NormalContainerListDesc->ContList.ListContainerCnt;
        Index--;
        Index %= NormalContainerListDesc->ContList.ListContainerCnt;

        NormalContainerListDesc->ContList.Index = Index;
        if (PHONE_TEXT_ID_TIME_OUT == NormalContainerListDesc->ContList.ContainerList[Index].Label.TxtId)
        {
            lv_obj_set_hidden(NormalContainerListDesc->ButtonBar.ButtonL.Button, FALSE);
        }
        else
        {
            lv_obj_set_hidden(NormalContainerListDesc->ButtonBar.ButtonL.Button, TRUE);
        }

        return(0);
    }
    else if (KEY_LEFT == key_val)
    {
        if (PHONE_TEXT_ID_INTENSITY == NormalContainerListDesc->ContList.ContainerList[Index].Label.TxtId)
        {
            Value              = lv_slider_get_value(NormalContainerListDesc->ContList.ContainerList[Index].u.Bar.Bar);
            BacklightIntensity = Setting_Backlight_Bar_Value_To_Intensity(Value);
            Hal_Backlight_Intensity_Set(Setting_Backlight_Intensity_To_Hal_Intensity(BacklightIntensity));
        }

        return(1);
    }
    else if (KEY_RIGHT == key_val)
    {
        if (PHONE_TEXT_ID_INTENSITY == NormalContainerListDesc->ContList.ContainerList[Index].Label.TxtId)
        {
            Value              = lv_slider_get_value(NormalContainerListDesc->ContList.ContainerList[Index].u.Bar.Bar);
            BacklightIntensity = Setting_Backlight_Bar_Value_To_Intensity(Value);
            Hal_Backlight_Intensity_Set(Setting_Backlight_Intensity_To_Hal_Intensity(BacklightIntensity));
        }

        return(1);
    }
    else if (KEY_SOFTLEFT == key_val)
    {
        if (PHONE_TEXT_ID_TIME_OUT == NormalContainerListDesc->ContList.ContainerList[Index].Label.TxtId)
        {
            Display_Setting_Backlight_Time_Out();
            return(1);
        }
        else
        {
            return(0);
        }
    }
    else if (KEY_OK == key_val)
    {
        // enter the selected setting item
        Value                                                          = lv_slider_get_value(NormalContainerListDesc->ContList.ContainerList[0].u.Bar.Bar);
        NormalContainerListDesc->ContList.ContainerList[0].u.Bar.Value = Value;
        BacklightIntensity                                             = Setting_Backlight_Bar_Value_To_Intensity(Value);
        Setting_Set_Backlight_Intensity(BacklightIntensity);
        Hal_Backlight_Intensity_Set(Setting_Backlight_Intensity_To_Hal_Intensity(BacklightIntensity));

        BacklightTimeout = Setting_TxtId_To_Backlight_Timeout(NormalContainerListDesc->ContList.ContainerList[1].u.Label2.TxtId);
        if (BacklightTimeout != g_SettingDisplaySettingMng.BacklightTimeout)
        {
            Setting_Set_Backlight_Timeout(BacklightTimeout);
        }

        Display_Setting_Done(ACT_ID_SETTING_BACKLIGHT, PHONE_TEXT_ID_DONE, ACT_ID_SETTING_DISPLAY_SETTINGS);

        return(1);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // Backlight Intensity return to previous status
        Hal_Backlight_Intensity_Set(Setting_Backlight_Intensity_To_Hal_Intensity(g_SettingDisplaySettingMng.BacklightIntensity));

        Setting_Get_Backlight_Time_Out_Req(&(g_SettingDisplaySettingMng.BacklightTimeout));

        // return to previous UI
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
} /* Display_Setting_Backlight_KeyCb */

/**
 * display Setting_Backlight
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Backlight(VOID)
{
    UINT8                           ListContainerCnt         = 0;
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;
    UI_Container_Base_Desc_t        *ContainerList           = NULL;
    Nav_Func_List_t                 FuncList;

    ListContainerCnt = 2;
    ContainerList    = (UI_Container_Base_Desc_t *)Hal_Mem_Alloc(ListContainerCnt * sizeof(UI_Container_Base_Desc_t));
    Hal_Mem_Set(ContainerList, 0, ListContainerCnt * sizeof(UI_Container_Base_Desc_t));

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(NormalContainerListDesc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    NormalContainerListDesc->TitleBar.TxtId      = PHONE_TEXT_ID_BACKLIGHT;
    NormalContainerListDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    NormalContainerListDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    ContainerList[0].Label.TxtId      = PHONE_TEXT_ID_INTENSITY;
    ContainerList[0].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    ContainerList[0].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[0].Valid            = TRUE;
    ContainerList[0].Choise           = UI_BASE_OBJ_BAR;
    ContainerList[0].u.Bar.Range      = 4;
    ContainerList[0].u.Bar.Value      = Setting_Backlight_Intensity_To_Bar_Value(g_SettingDisplaySettingMng.BacklightIntensity);
    ContainerList[0].u.Bar.BarAlign   = LV_ALIGN_IN_BOTTOM_LEFT;

    ContainerList[1].Label.TxtId         = PHONE_TEXT_ID_TIME_OUT;
    ContainerList[1].Label.TxtAlign      = LV_LABEL_ALIGN_LEFT;
    ContainerList[1].Label.LabelAlign    = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[1].Valid               = TRUE;
    ContainerList[1].Choise              = UI_BASE_OBJ_LABEL;
    ContainerList[1].u.Label2.TxtId      = Setting_Backlight_Timeout_To_TxtId(g_SettingDisplaySettingMng.BacklightTimeout);
    ContainerList[1].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    ContainerList[1].u.Label2.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    NormalContainerListDesc->ContList.ListContainerCnt = ListContainerCnt;
    NormalContainerListDesc->ContList.Index            = 0;
    NormalContainerListDesc->ContList.ContainerList    = ContainerList;

    NormalContainerListDesc->ButtonBar.ButtonL.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_CHANGE;

    NormalContainerListDesc->ButtonBar.ButtonM.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_SAVE;

    NormalContainerListDesc->ButtonBar.ButtonR.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalContainerListDesc->KeyFunc = Display_Setting_Backlight_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_Container_List_Create;
    FuncList.OnDestroy = Display_Setting_Backlight_Destroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_BACKLIGHT, &FuncList, (VOID *)NormalContainerListDesc);
    gp_SettingDisplayCurUIDesc = (VOID *)NormalContainerListDesc;

    lv_obj_set_hidden(NormalContainerListDesc->ButtonBar.ButtonL.Button, TRUE);
} /* Display_Setting_Backlight */

/**
 * Callback Function of Setting_Backlight
 * param (in) Btn: lv_obj_t*
 * param (in) Event: lv_event_t
 * return void:
 */
VOID Display_Setting_Backlight_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Backlight();
    }
}

/**
 * sub-module entry
 * param (in) StandbyScreenMode: SETTING_STANDBY_SCREEN
 * return TxtId: UINT16
 */
UINT16 Setting_Standby_Screen_Mode_To_TxtId(SETTING_STANDBY_SCREEN StandbyScreenMode)
{
    UINT16 TxtId = LV_LANG_TXT_ID_NONE;

    switch (StandbyScreenMode)
    {
    case SETTING_STANDBY_SCREEN_OFF:
        TxtId = PHONE_TEXT_ID_OFF;
        break;

    case SETTING_STANDBY_SCREEN_ON:
        TxtId = PHONE_TEXT_ID_ON;
        break;

    case SETTING_STANDBY_SCREEN_1_HOUR:
        TxtId = PHONE_TEXT_ID_TIME_OUT_1HOUR;
        break;

    default:
        break;
    }

    return(TxtId);
}

/**
 * sub-module entry
 * param (in) StandbyScreenMode: SETTING_STANDBY_SCREEN
 * return Index: UINT8
 */
UINT8 Setting_Standby_Screen_To_Index(SETTING_STANDBY_SCREEN StandbyScreenMode)
{
    UINT8 Index;

    switch (StandbyScreenMode)
    {
    case SETTING_STANDBY_SCREEN_ON:
        Index = 0;
        break;

    case SETTING_STANDBY_SCREEN_OFF:
        Index = 1;
        break;

    case SETTING_STANDBY_SCREEN_1_HOUR:
        Index = 2;
        break;

    default:
        break;
    }

    return(Index);
}

/**
 * sub-module entry
 * param (in) StandbyScreenMode: SETTING_STANDBY_SCREEN
 * return Index: UINT8
 */
SETTING_STANDBY_SCREEN Setting_Index_To_Standby_Screen(UINT8 Index)
{
    SETTING_STANDBY_SCREEN StandbyScreenMode;

    switch (Index)
    {
    case 0:
        StandbyScreenMode = SETTING_STANDBY_SCREEN_ON;
        break;

    case 1:
        StandbyScreenMode = SETTING_STANDBY_SCREEN_OFF;
        break;

    case 2:
        StandbyScreenMode = SETTING_STANDBY_SCREEN_1_HOUR;
        break;

    default:
        StandbyScreenMode = SETTING_STANDBY_SCREEN_ON;
        break;
    }

    return(StandbyScreenMode);
}

/**
 * set standby screen
 * param (in) Standby: SETTING_STANDBY_SCREEN
 * return  void
 */
VOID Setting_Set_Standby_Screen(SETTING_STANDBY_SCREEN Standby)
{
    // update global variable
    UINT8 nvData;

    // change global variable
    g_SettingDisplaySettingMng.StandbyScreenMode = Standby;

    // nv write
    nvData = (UINT8)Standby;
    UI_NV_Write_Req(NV_SECTION_UI_SETTINGS, (NV_SETTING_DISPLAY_SETTING_OFFSET + 3), 1, &nvData);
}

/**
 *
 * Callback of Display_Setting_Standby_Screen, on destroy
 * param (in) pNormalLstOnlyDesc: UI_Normal_List_Only_Desc_t*
 * return void:
 */
VOID Display_Setting_Standby_Screen_Destroy(VOID *pPara)
{
    UI_Normal_List_Only_Desc_t *pNormalLstOnlyDesc = NULL;

    pNormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)pPara;

    Hal_Mem_Free(pNormalLstOnlyDesc->List.ButtonList);
    Hal_Mem_Free(pNormalLstOnlyDesc);
}

/**
 *
 * Display_Setting_Backlight_Time_Out_KeyCb
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Standby_Screen_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_List_Only_Desc_t *pNormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)gp_SettingDisplayCurUIDesc;
    UINT8                      Index               = pNormalLstOnlyDesc->List.Index;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    if (KEY_DOWN == key_val)
    {
        Index++;
        Index %= pNormalLstOnlyDesc->List.ListButtonCnt;

        pNormalLstOnlyDesc->List.Index = Index;

        return(0);
    }
    else if (KEY_UP == key_val)
    {
        Index += pNormalLstOnlyDesc->List.ListButtonCnt;
        Index--;
        Index %= pNormalLstOnlyDesc->List.ListButtonCnt;

        pNormalLstOnlyDesc->List.Index = Index;

        return(0);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // return to previous UI
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
} /* Display_Setting_Standby_Screen_KeyCb */

/**
 * Standby Screen call back
 * param (in) Btn: lv_obj_t*
 * param (in) Event: lv_event_t
 * return  void
 */
VOID Display_Setting_Standby_Screen_CallBack(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Setting_Phone_Setting_t         *PhoneSetting;
        SETTING_STANDBY_SCREEN          Standby;
        UI_Normal_List_Only_Desc_t      *pNormalLstOnlyDesc      = (UI_Normal_List_Only_Desc_t *)gp_SettingDisplayCurUIDesc;
        UI_Normal_Container_List_Desc_t *NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)gp_SettingDisplayCurContainerListUIDesc;

        // enter the selected setting item
        Standby = Setting_Index_To_Standby_Screen(pNormalLstOnlyDesc->List.Index);
        if (Standby != g_SettingDisplaySettingMng.StandbyScreenMode)
        {
            Setting_Set_Standby_Screen(Standby);
            PhoneSetting = (Setting_Phone_Setting_t *)Hal_Mem_Alloc(sizeof(Setting_Phone_Setting_t));
            Hal_Mem_Set(PhoneSetting, 0, sizeof(Setting_Phone_Setting_t));
            PhoneSetting->ChangeMark |= IF_SETTING_CHANGE_MARK_STANDBY_SCREEN_MODE;
            if (SETTING_STANDBY_SCREEN_OFF == Standby)
            {
                PhoneSetting->StandbyScreenMode = IF_SETTING_STANDBY_SCREEN_OFF;
            }
            else if (SETTING_STANDBY_SCREEN_ON == Standby)
            {
                PhoneSetting->StandbyScreenMode = IF_SETTING_STANDBY_SCREEN_ON;
            }

            Setting_Phone_Setting_Chg_Ind(PhoneSetting);
        }

        NormalContainerListDesc->ContList.ContainerList[NormalContainerListDesc->ContList.Index].u.Label2.TxtId
            = Setting_Standby_Screen_Mode_To_TxtId(Standby);

        Display_Setting_Done(ACT_ID_SETTING_STANDBY_SCREEN, PHONE_TEXT_ID_DONE, ACT_ID_SETTING_DISPLAY_SETTINGS);
    }
}

/**
 * display Setting_Standby_Screen
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Standby_Screen(VOID)
{
    Nav_Func_List_t            FuncList;
    UI_Normal_List_Only_Desc_t *pNormalLstOnlyDesc;

    pNormalLstOnlyDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(pNormalLstOnlyDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    pNormalLstOnlyDesc->TitleBar.TxtId      = PHONE_TEXT_ID_TIME_OUT;
    pNormalLstOnlyDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pNormalLstOnlyDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    pNormalLstOnlyDesc->List.Index         = Setting_Standby_Screen_To_Index(g_SettingDisplaySettingMng.StandbyScreenMode);
    pNormalLstOnlyDesc->List.ListButtonCnt = 2;
    pNormalLstOnlyDesc->List.ButtonList    = (UI_Button_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Button_Desc_t) * pNormalLstOnlyDesc->List.ListButtonCnt);
    Hal_Mem_Set(pNormalLstOnlyDesc->List.ButtonList, 0, sizeof(UI_Button_Desc_t) * pNormalLstOnlyDesc->List.ListButtonCnt);

    pNormalLstOnlyDesc->List.ButtonList[0].ButtonIndex = 0;
    pNormalLstOnlyDesc->List.ButtonList[0].TxtId       = PHONE_TEXT_ID_ON;
    pNormalLstOnlyDesc->List.ButtonList[0].Valid       = TRUE;
    pNormalLstOnlyDesc->List.ButtonList[0].ReleaseFun  = Display_Setting_Standby_Screen_CallBack;

    pNormalLstOnlyDesc->List.ButtonList[1].ButtonIndex = 1;
    pNormalLstOnlyDesc->List.ButtonList[1].TxtId       = PHONE_TEXT_ID_OFF;
    pNormalLstOnlyDesc->List.ButtonList[1].Valid       = TRUE;
    pNormalLstOnlyDesc->List.ButtonList[1].ReleaseFun  = Display_Setting_Standby_Screen_CallBack;

    /* pNormalLstOnlyDesc->List.ButtonList[2].ButtonIndex = 2; */
    /* pNormalLstOnlyDesc->List.ButtonList[2].TxtId       = PHONE_TEXT_ID_TIME_OUT_1HOUR; */
    /* pNormalLstOnlyDesc->List.ButtonList[2].Valid       = TRUE; */
    /* pNormalLstOnlyDesc->List.ButtonList[2].ReleaseFun  = Display_Setting_Standby_Screen_CallBack; */

    pNormalLstOnlyDesc->BtnBar.ButtonL.Valid = FALSE;

    pNormalLstOnlyDesc->BtnBar.ButtonM.Valid = TRUE;
    pNormalLstOnlyDesc->BtnBar.ButtonM.TxtId = PHONE_TEXT_ID_OK;

    pNormalLstOnlyDesc->BtnBar.ButtonR.Valid = TRUE;
    pNormalLstOnlyDesc->BtnBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    pNormalLstOnlyDesc->KeyFunc = Display_Setting_Standby_Screen_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_List_Only_Create;
    FuncList.OnDestroy = Display_Setting_Standby_Screen_Destroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_STANDBY_SCREEN, &FuncList, pNormalLstOnlyDesc);
    gp_SettingDisplayCurUIDesc = (VOID *)pNormalLstOnlyDesc;
} /* Display_Setting_Standby_Screen */

/**
 * Callback Function of Setting_Standby_Screen
 * param (in) Btn: lv_obj_t*
 * param (in) Event: lv_event_t
 * return void:
 */
VOID Display_Setting_Standby_Screen_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Standby_Screen();
    }
}

/**
 *
 * Callback of Display_Setting_Display_Settings, on destroy
 * param (in) NormalContainerListDesc: UI_Normal_Container_List_Desc_t*
 * return void:
 */
VOID Display_Setting_Display_Settings_Destroy(VOID *pPara)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)pPara;

    Hal_Mem_Free(NormalContainerListDesc->ContList.ContainerList);
    Hal_Mem_Free(NormalContainerListDesc);
}

/**
 *
 * Display_Setting_Display_Settings
 * param (in) obj: lv_obj_t*
 *       (in) key_sta: UI_KEY_STATUS
 *       (in) key_val: UI_KEY_VALUE
 * return UINT8: 0--call system handling outside
 *               1--handled inside
 */
UINT8 Display_Setting_Display_Settings_KeyCb(lv_obj_t *obj, UI_KEY_STATUS key_sta, UI_KEY_VALUE key_val)
{
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc;

    if (KEY_RELEASED != key_sta)
    {
        return(0);
    }

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)gp_SettingDisplayCurContainerListUIDesc;

    if (KEY_DOWN == key_val)
    {
        NormalContainerListDesc->ContList.Index++;
        NormalContainerListDesc->ContList.Index %= NormalContainerListDesc->ContList.ListContainerCnt;
        return(0);
    }
    else if (KEY_UP == key_val)
    {
        NormalContainerListDesc->ContList.Index += NormalContainerListDesc->ContList.ListContainerCnt;
        NormalContainerListDesc->ContList.Index--;
        NormalContainerListDesc->ContList.Index %= NormalContainerListDesc->ContList.ListContainerCnt;
        return(0);
    }
    else if (KEY_SOFTRIGHT == key_val)
    {
        // return to previous UI
        Nav_Back(ACT_ID_ANY);
        return(1);
    }
    else if (KEY_END == key_val)
    {
        Nav_Home(ACT_ID_ANY);
        return(1);
    }
    else
    {
        return(0);
    }
} /* Display_Setting_Display_Settings_KeyCb */

/**
 * display Setting_Display_Settings
 * param (in) void:
 * return void:
 */
VOID Display_Setting_Display_Settings(VOID)
{
    UINT8                           ListContainerCnt         = 0;
    UI_Normal_Container_List_Desc_t *NormalContainerListDesc = NULL;
    UI_Container_Base_Desc_t        *ContainerList           = NULL;
    Nav_Func_List_t                 FuncList;

    ListContainerCnt = 3;
    ContainerList    = (UI_Container_Base_Desc_t *)Hal_Mem_Alloc(ListContainerCnt * sizeof(UI_Container_Base_Desc_t));
    Hal_Mem_Set(ContainerList, 0, ListContainerCnt * sizeof(UI_Container_Base_Desc_t));

    NormalContainerListDesc = (UI_Normal_Container_List_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(NormalContainerListDesc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    NormalContainerListDesc->TitleBar.TxtId      = PHONE_TEXT_ID_DISPLAY_SETTINGS;
    NormalContainerListDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    NormalContainerListDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;

    ContainerList[0].Label.TxtId         = PHONE_TEXT_ID_WALLPAPER;
    ContainerList[0].Label.TxtAlign      = LV_LABEL_ALIGN_LEFT;
    ContainerList[0].Label.LabelAlign    = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[0].Valid               = TRUE;
    ContainerList[0].Choise              = UI_BASE_OBJ_LABEL;
    ContainerList[0].u.Label2.TxtId      = SettingWallPaterList[g_SettingDisplaySettingMng.CurrentWallPaperIndex].WallpaperNameID;
    ContainerList[0].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    ContainerList[0].u.Label2.LabelAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    ContainerList[0].ReleaseFunc         = Display_Setting_Wallpapers_Cb;

    ContainerList[1].Label.TxtId      = PHONE_TEXT_ID_BACKLIGHT;
    ContainerList[1].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
    ContainerList[1].Label.LabelAlign = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[1].Valid            = TRUE;
    ContainerList[1].Choise           = UI_BASE_OBJ_NULL;
    ContainerList[1].ReleaseFunc      = Display_Setting_Backlight_Cb;

    ContainerList[2].Label.TxtId         = PHONE_TEXT_ID_STANDBY_SCREEN;
    ContainerList[2].Label.TxtAlign      = LV_LABEL_ALIGN_LEFT;
    ContainerList[2].Label.LabelAlign    = LV_ALIGN_IN_TOP_LEFT;
    ContainerList[2].Valid               = TRUE;
    ContainerList[2].Choise              = UI_BASE_OBJ_LABEL;
    ContainerList[2].u.Label2.TxtId      = Setting_Standby_Screen_Mode_To_TxtId(g_SettingDisplaySettingMng.StandbyScreenMode);
    ContainerList[2].u.Label2.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    ContainerList[2].u.Label2.LabelAlign = LV_ALIGN_IN_BOTTOM_LEFT;
    ContainerList[2].ReleaseFunc         = Display_Setting_Standby_Screen_Cb;

    NormalContainerListDesc->ContList.ListContainerCnt = ListContainerCnt;
    NormalContainerListDesc->ContList.Index            = 0;
    NormalContainerListDesc->ContList.ContainerList    = ContainerList;

    NormalContainerListDesc->ButtonBar.ButtonL.Valid = FALSE;

    NormalContainerListDesc->ButtonBar.ButtonM.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonM.TxtId = PHONE_TEXT_ID_SELECT;

    NormalContainerListDesc->ButtonBar.ButtonR.Valid = TRUE;
    NormalContainerListDesc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    NormalContainerListDesc->KeyFunc = Display_Setting_Display_Settings_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Normal_Container_List_Create;
    FuncList.OnDestroy = Display_Setting_Display_Settings_Destroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_SETTING_DISPLAY_SETTINGS, &FuncList, (VOID *)NormalContainerListDesc);
    gp_SettingDisplayCurContainerListUIDesc = (VOID *)NormalContainerListDesc;
} /* Display_Setting_Display_Settings */

/**
 *
 * Callback of Display_Setting_Settings
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void:
 */
VOID Display_Setting_Display_Settings_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if(LV_EVENT_CLICKED == Event)
    {
        Display_Setting_Display_Settings();
    }
}
